package com.cn.goodsadmin.requestinfo;

import com.alibaba.fastjson.JSONObject;
import com.cn.goodsadmin.common.frame.BaseNetAns;
import com.cn.goodsadmin.common.frame.BaseNetWork;

public class GetAcessTokenAns extends BaseNetAns {

    public String aceesToken;

    @Override
    public void onReceiveAns(BaseNetWork baseNetWork) {
        byte[] content = baseNetWork.content;
        try {
            JSONObject object = JSONObject.parseObject(new String(content, "UTF-8"));
            int retCode = object.getInteger("retcode");
            if (retCode == 0 && object.containsKey("acesstoken")) {
                aceesToken = object.getString("acesstoken");
            } else {
                isError = true;
            }
        } catch (Exception e) {
            isError = true;
        }
    }

    @Override
    public void onReadyAns(BaseNetWork baseNetWork) {

    }

    @Override
    public void onStartAns(BaseNetWork baseNetWork) {

    }

    @Override
    public void onDowningAns(byte[] buf, int len, long downsize, BaseNetWork baseNetWork) {

    }

    @Override
    public void onStopAns(BaseNetWork baseNetWork) {
        isError = true;
    }

    @Override
    public void onErrorAns(BaseNetWork baseNetWork) {
        isError = true;
    }
}
